/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2022-10-05
 * Time:16:52
 */
class Base{
    String var="EJava";
    void printVar(){
        System.out.println(var);
    }
}
class Derived extends Base{
    String var="Guru";
    void printVar(){
        System.out.println(var);
    }
}
public class TestDemo {
    public static void main(String[] args) {
        Base base=new Base();
        Base derived=new Derived();
        System.out.println(base.var);//eJava
        System.out.println(derived.var);//多态中，当父类和子类的成员变量名相同时，调用的成员变量还是父类的成员变量
        base.printVar();//"EJava"
        derived.printVar();//"Guru"
    }
}
